#include "UserRtc.h"

/**
 * @brief  获取时间测试
 * @note   
 * @retval None
 */
void getRealTime(void)
{
	RTC_TimeTypeDef time = {0};
	RTC_DateTypeDef datebuff = {0};
	HAL_RTC_GetTime(&hrtc, &time, RTC_FORMAT_BIN);
	HAL_RTC_GetDate(&hrtc, &datebuff, RTC_FORMAT_BIN);
	HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR2, (uint16_t)datebuff.Year);
	HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR3, (uint16_t)datebuff.Month);
	HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR4, (uint16_t)datebuff.Date);
	HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR5, (uint16_t)datebuff.WeekDay);
	printf("%d-%d-%d-%d-", datebuff.Year, datebuff.Month, datebuff.Date, datebuff.WeekDay);
	printf("%d:%d:%d\r\n", time.Hours, time.Minutes, time.Seconds);
}
/**
 * @brief  秒中断
 * @note   
 * @param  *hrtc: 
 * @retval None
 */
void HAL_RTCEx_RTCEventCallback(RTC_HandleTypeDef *hrtc)
{
	if (hrtc->Instance == RTC)
	{
		getRealTime();
	}
}
